package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.live_comment.*;
import com.yxw.live_vod_boot.service.LiveCommentService;
import com.yxw.live_vod_boot.vo.*;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "直播评论管理", tags = "直播评论管理")
@Slf4j
@RequestMapping("/api/live/comment")
public class LiveCommentController {

    @Autowired
    private LiveCommentService liveCommentService;

    /**
     * 新增直播评论
     */
    @ApiOperation(value = "新增直播评论 MQTT主题：LIVE_COMMENT_TOPIC_ + liveId")
    @PostMapping(value = "/addComment")
    public BaseResult addComment(@RequestBody @Validated LiveCommentDTO dto) {
        LiveCommentVO vo = liveCommentService.addComment(dto);
        return BaseResult.doSuccess(vo, "评论成功");
    }

    /**
     * 查询某一直播间下的评论列表
     */
    @ApiOperation(value = "查询某一直播间下的评论列表")
    @PostMapping(value = "/getLiveCommentLisByLiveId")
    public BaseResult<PageVO<LiveCommentVO>> getLiveCommentLisByLiveId(@RequestBody @Validated LiveCommentQueryDTO dto) {
        PageVO<LiveCommentVO> commentList = liveCommentService.getLiveCommentLisByLiveId(dto);
        return BaseResult.doSuccess(commentList, "查询评论列表成功");
    }

    /**
     * 查询某一直播间下的评论总数和评论人数量
     */
    @ApiOperation(value = "查询某一直播间下的评论总数和评论人数量")
    @PostMapping(value = "/getCommentStatsByLiveId")
    public BaseResult<LiveCommentStatsVO> getCommentStatsByLiveId(@RequestBody @Validated LiveCommentQueryDTO dto) {
        LiveCommentStatsVO commentStats = liveCommentService.getCommentStatsByLiveId(dto);
        return BaseResult.doSuccess(commentStats, "查询评论统计成功");
    }

    /**
     * 禁言直播间中某一个用户
     */
    @ApiOperation(value = "禁言直播间中某一个用户")
    @PostMapping(value = "/silencedUser")
    public BaseResult silencedUser(@RequestBody @Validated LiveCommentSilencedUserDTO dto) {
        liveCommentService.silencedUser(dto);
        return BaseResult.doSuccess(null, "禁言成功");
    }

    /**
     * 解除禁言
     */
    @ApiOperation(value = "解除禁言-直播间中某一个用户")
    @PostMapping(value = "/deleteSilencedUser")
    public BaseResult deleteSilencedUser(@RequestBody @Validated LiveCommentSilencedUserDeleteDTO dto) {
        liveCommentService.deleteSilencedUser(dto);
        return BaseResult.doSuccess(null, "解除禁言成功");
    }

    /**
     * 查询直播间中被禁言用户列表
     */
    @ApiOperation(value = "查询直播间中被禁言用户列表")
    @PostMapping(value = "/getSilencedUserList")
    public BaseResult<PageVO<LiveSilencedUserVO>> getSilencedUserList(@RequestBody @Validated LiveCommentSilencedUserQueryDTO dto) {
        PageVO<LiveSilencedUserVO> vo = liveCommentService.getSilencedUserList(dto);
        return BaseResult.doSuccess(vo, "查询成功");
    }

    /**
     * 拉黑直播间中某一个用户
     */
    @ApiOperation(value = "拉黑直播间中某一个用户")
    @PostMapping(value = "/bannedUser")
    public BaseResult bannedUser(@RequestBody @Validated LiveBannedUserDTO dto) {
        liveCommentService.bannedUser(dto);
        return BaseResult.doSuccess(null, "拉黑成功");
    }

    /**
     * 解除拉黑
     */
    @ApiOperation(value = "解除拉黑-直播间中某一个用户")
    @PostMapping(value = "/deleteBannedUser")
    public BaseResult deleteBannedUser(@RequestBody @Validated LiveBannedUserDeleteDTO dto) {
        liveCommentService.deleteBannedUser(dto);
        return BaseResult.doSuccess(null, "解除拉黑成功");
    }

    /**
     * 查询直播间中被拉黑用户列表
     */
    @ApiOperation(value = "查询直播间中被拉黑用户列表")
    @PostMapping(value = "/getBannedUserList")
    public BaseResult<PageVO<LiveBannedUserVO>> getBannedUserList(@RequestBody @Validated LiveBannedUserQueryDTO dto) {
        PageVO<LiveBannedUserVO> vo = liveCommentService.getBannedUserList(dto);
        return BaseResult.doSuccess(vo, "查询成功");
    }

    /**
     * 直播结束后获取互动数据
     */
    @ApiOperation(value = "直播结束后获取互动数据")
    @PostMapping(value = "/getLiveInteractiveDataAfterLiveEnd")
    public BaseResult<LiveInteractiveDataVO> getLiveInteractiveDataAfterLiveEnd(@RequestBody @Validated LiveInteractiveDataQueryDTO dto) {
        LiveInteractiveDataVO vo = liveCommentService.getLiveInteractiveDataAfterLiveEnd(dto);
        return BaseResult.doSuccess(vo, "查询成功");
    }
}